package day1103;
//游戏

import java.util.Scanner;

public class Game {
    Scanner input = new Scanner(System.in);
    String name = "手速游戏";
    Level l[] = new Level[6];
    int pos = 0;
    int exp = 0;
    String x="";

    @Override
    public String toString() {
        return "Game{" +
                "欢迎来到='" + name + '\'' +
                '}';
    }

    public void chushihua(){
        l[0]=new Level(1,0,5,10,3);
        l[1]=new Level(2,20,5,20,5);
        l[2]=new Level(3,40,5,30,7);
        l[3]=new Level(4,60,5,40,9);
        l[4]=new Level(5,80,5,50,11);
        l[5]=new Level(6,100,5,60,13);
    }
    public void show(){
        for (int i = 0;i<l.length;i++){
            System.out.println(l[i].toString());
        }
    }
    public void determine() {
        for (; ; ) {
            Math. random();
            for (int i = 0;i<l[pos].getLength();i++){
                char a= (char) (Math. random()*(127-32) +32);//32 ---126]
                x+=a;
            }
            System.out.println("----------------开始游戏--------------");
            System.out.println("请按照提示输入相同字符");
            System.out.println(x);
            long start = System.currentTimeMillis();
            double time =0;
            String y = input.next();
            long end = System.currentTimeMillis();
            time = (end-start)/1000;
            if (x.equals(y)&&time<=l[pos].getTime()) {
                System.out.println("耗时:" +time+"秒");
                System.out.println("输入正确，经验值+5");
                exp += l[pos].getIncreasing();
                for (int i = 0; i < 6; i++) {
                    if (exp >= l[i].getEXP()) {
                        pos=i;
                    }
                }
                System.out.println("等级为：" + l[pos].getGradenum() + "经验值为：" + exp);
            }else {
                System.out.println("超时或输入错误");
                return;
            }
        }

    }

}
